{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 4: Figures"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Robert Johansson\n",
    "\n",
    "Source code listings for [Numerical Python - Scientific Computing and Data Science Applications with Numpy, SciPy and Matplotlib](https://www.apress.com/us/book/9781484242452) (ISBN 978-1-484242-45-2)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "# %matplotlib inline\n",
    "%config InlineBackend.figure_format='retina'\n",
    "import matplotlib.pyplot as plt\n",
    "import matplotlib as mpl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "fig = plt.figure()\n",
    "\n",
    "ax = fig.add_axes([0.05, 0.05, .88, 00.88])\n",
    "ax.set_yticks([])\n",
    "ax.set_xticks([])\n",
    "ax.text(0.001, 0.01, \"(0,0)\")\n",
    "ax.text(1.001, 0.01, \"(1,0)\")\n",
    "ax.text(0.001, 1.01, \"(0,1)\")\n",
    "ax.text(1.001, 1.01, \"(1,1)\")\n",
    "ax.text(0.02, 0.92, \"Figure\", fontsize=18)\n",
    "\n",
    "ax.text(0.12, 0.06, \"(0.15, 0.15)\")\n",
    "\n",
    "ax = fig.add_axes([0.15, 0.15, 0.68, 0.66])\n",
    "ax.text(0.03, 0.88, \"Axes\", fontsize=18)\n",
    "ax.set_yticks([])\n",
    "ax.set_xticks([])\n",
    "\n",
    "\n",
    "fig.savefig(\"figure-axes-schematic.pdf\");"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "fig = plt.figure()\n",
    "\n",
    "\n",
    "ax.text(0.12, 0.06, \"(0.15, 0.15)\")\n",
    "\n",
    "ax = fig.add_axes([0.15, 0.15, 0.68, 0.66])\n",
    "ax.set_yticks([1, 2, 3])\n",
    "ax.set_xticks([1, 2, 3])\n",
    "\n",
    "#ax.set_yticklabels(['', '', ''])\n",
    "\n",
    "ax.set_xlabel(\"x axis\", fontsize=18)\n",
    "ax.set_ylabel(\"y axis\", fontsize=18)\n",
    "\n",
    "ax.set_xlim(1,3)\n",
    "ax.set_ylim(1,3)\n",
    "\n",
    "ax.xaxis.set_minor_locator(mpl.ticker.MultipleLocator(0.25))\n",
    "ax.yaxis.set_minor_locator(mpl.ticker.MultipleLocator(0.25))\n",
    "\n",
    "ax.annotate(\"Major tick\",\n",
    "         xy=(1, 2), xycoords='data',\n",
    "         xytext=(+35, +30), textcoords='offset points', fontsize=16,\n",
    "         arrowprops=dict(arrowstyle=\"->\", connectionstyle=\"arc3, rad=.2\"))\n",
    "\n",
    "ax.annotate(\"Minor tick\",\n",
    "         xy=(1, 1.5), xycoords='data',\n",
    "         xytext=(+35, +30), textcoords='offset points', fontsize=16,\n",
    "         arrowprops=dict(arrowstyle=\"->\", connectionstyle=\"arc3, rad=.2\"))\n",
    "\n",
    "fig.savefig(\"figure-axis-schematic.pdf\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Versions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "%reload_ext version_information"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [],
   "source": [
    "%version_information numpy, matplotlib"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
